﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using Utility.Log;

namespace Utility.Network
{
    class TcpSock
    {
        public void StartListen(IPAddress ip, int port) 
        {
            IPEndPoint localEndPoint = new IPEndPoint(ip,port);
            Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            // Bind the socket to the local endpoint and  listen for incoming connections. 
            try
            {
                listener.Bind(localEndPoint);
                listener.Listen(20);//20 trucks
                // Start listening for connections. 
                while (true)
                {
                    // here will be suspended while waiting for a new connection. 
                    Socket connection = listener.Accept();
                }
            }
            catch { }
        }
    }
}
